Zip for WinRT
Open a Zip File from Users Machine

You can allow the user to select and open a Zip file from their documents library using the FileOpenPicker class. Use the following code to open a file with C1Zip. This sample also assumes you have a C1FlexGrid control on your page named “flex” to display the results, however this is not necessary.

C#
Copy Code
// open an existing zip file
async void _btnOpen_Click_1(object sender, RoutedEventArgs e)
{
    C1ZipFile zip = new C1ZipFile(new System.IO.MemoryStream(), true);
    try
    {
        var picker = new Windows.Storage.Pickers.FileOpenPicker();
        picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
        picker.FileTypeFilter.Add(".zip");

        var file = await picker.PickSingleFileAsync();
        if (file != null)
        {
            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
            zip.Open(stream.AsStream());
           
            // Load entries into FlexGrid
            flex.ItemsSource = zip.Entries;
        }
    }
    catch (Exception x)
    {
        System.Diagnostics.Debug.WriteLine(x.Message);
    }
}
See Also

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback